package com.xuanyuan.base;

import android.app.Application;

import androidx.lifecycle.ProcessLifecycleOwner;

import com.xuanyuan.base.listener.LifecycleListener;
import com.xuanyuan.base.listener.SimpleAppLifecycleCallback;
import com.xuanyuan.base.utils.ContextUtil;

/**
 * @author ken.luo
 * @version V1.0
 * @FileName:
 * @Description:
 * @date 2023/4/4
 * @email 424533553@qq.com
 */
public class RootApplication extends Application {
    @Override
    public void onCreate() {
        super.onCreate();

        ContextUtil.init(this);

        registerLifecycleCallbacks();


    }


    /**
     * 注册生命周期监听
     */
    private void registerLifecycleCallbacks() {
        registerActivityLifecycleCallbacks(new com.xuanyuan.base.listener.ActivityLifecycleCallbacks());
        LifecycleListener lifecycleListener = new LifecycleListener();
        lifecycleListener.addCallback(new SimpleAppLifecycleCallback());
        ProcessLifecycleOwner.get().getLifecycle().addObserver(lifecycleListener);
    }

}
